package com.atguigu.controller;

import com.atguigu.entities.TUser;
import com.atguigu.entities.User;
import com.atguigu.service.TUserService;
import com.atguigu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: shenhao
 * @CreatTime: 2024/10/5 16:30
 * @Version: 1.0
 * 测试Java自带的HTTP测试工具
 */
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/user/add")
    public int addUser(@RequestBody User user) {
        return userService.addUser(user);
    }

    @GetMapping("/user/{id}")
    public User getUser(@PathVariable int id) {
        return userService.getUserById(id);
    }

    @Autowired
    private TUserService tUserService;
    @PostMapping("/tuser/add")
    public int addTUser(@RequestBody TUser user) {
        return tUserService.addUser(user);
    }

    @GetMapping("/tuser/{id}")
    public TUser getTUser(@PathVariable int id) {
        return tUserService.getUserById(id);
    }
}
